package cn.wetcland.urban.framework.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.framework.annotation.SaCheckDriverLogin;
import cn.wetcland.urban.framework.service.UtNoticeService;
import cn.wetcland.urban.framework.vo.NoticeListItemVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Resource
    public UtNoticeService noticeService;

    @GetMapping("/getConsumerNoticeList")
    @SaCheckLogin
    public AjaxResponse getConsumerNoticeList() {
        List<NoticeListItemVO> consumerNoticeList = noticeService.getConsumerNoticeList();
        return AjaxResponse.success(consumerNoticeList);
    }

    @GetMapping("/getDriverNoticeList")
    @SaCheckDriverLogin
    public AjaxResponse getDriverNoticeList() {
        List<NoticeListItemVO> consumerNoticeList = noticeService.getDriverNoticeList();
        return AjaxResponse.success(consumerNoticeList);
    }

    @GetMapping("/getNoticeDetails/{noticeId}")
    public AjaxResponse getNoticeDetails(@PathVariable Long noticeId) {
        NoticeListItemVO noticeDetails = noticeService.getNoticeDetails(noticeId);
        return AjaxResponse.success(noticeDetails);
    }

}
